<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let n = parseInt(prompt("请输入一个整数"));
        let scale = parseInt(prompt("请输入你想要转化的进制数"));
        // let arr = [];


        function conver(a, b) {
            let arr = [];
            let c;

            while (a > 0) {

                let c = a % b;

                if (b == 16) {
                    switch (c) {
                        case 10:
                            c = 'A';
                            break;
                        case 11:
                            c = 'B';
                            break;
                        case 12:
                            c = 'C';
                            break;
                        case 13:
                            c = 'D';
                            break;
                        case 14:
                            c = 'E';
                            break;
                        case 15:
                            c = 'F';
                            break;

                    }
                }
                arr.unshift(c);
                a = Math.floor(a / b);


            }
            let t = arr.join("");
            return t;
        }

        console.log(conver(n, scale));
    </script>
</body>

</html>